package com.example.laundry.controller;

import com.example.laundry.dto.JwtResponseDto;
import com.example.laundry.dto.UserLoginDto;
import com.example.laundry.service.AuthService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

@RestController
@RequestMapping("/api/auth")
@Tag(name = "Authentication", description = "Authentication APIs")
public class LoginController {

    @Autowired
    private AuthService authService;

    @PostMapping("/login")
    @Operation(summary = "Authenticate user")
    public ResponseEntity<JwtResponseDto> login(@Valid @RequestBody UserLoginDto loginDto) {
        JwtResponseDto response = authService.authenticateUser(loginDto);
        return ResponseEntity.ok(response);
    }
}